Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

194
Vistas
exception: "Symfony\Component\HttpKernel\Exception\NotFoundHttpException",…

I am a newbie to jquery and ajax and I am using laravel in my backend,"I must say the codes below works perfectly fine for just one of my pages but other pages I get the error above". I tried to load my jquery datatables data via ajax so I performed a jquery ajax call to my route as below:

ajax:
    
        {
            type    : "get",
            url     : "{{URL::asset('AgencyExpenses')}}",
            dataType: "json",
        },
        columns: 
        [
            {"data":"id"},
            {"data":"agency_id"},
            {"data":"amount"},
            {"data":"date"},
            {"data":"description"},
            {"data":"address"},
            {
                "data": null,
                render: function(data,row,type){
                    return '<button class="btn btn-trans btn-sm btn-primary fa fa-pencil text-primary" data-toggle="collapse" data-target="#collapsable" ></button>'
                }
                
            },
            {
                "data": null,
                render: function(data,row,type){
                    return '<button class="btn btn-trans btn-sm btn-danger fa fa-trash text-danger"></button>'
                }
                
            },
        ],
        autofill: true,
        select: true,
        responsive: true,
        buttons: true,
        length: 10,
    }
    

my "web.php" route is:

Route::get('AgencyExpenses',[AgencyExpController::class, 'expense']);

and my controller returns this function:

public function expense()
{
    $expense = AgencyExp::all();
    return response()->json([
        'data' => $expense,
    ]);
}

but every time the page loads this message displays: jquery datatable error

in network the fetch/xhr returns 404 status code with the following exceptions:

"", exception: "Symfony\Component\HttpKernel\Exception\NotFoundHttpException",…}

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

I had to clear the routes cache by executing two command listed below:

php artisan optimize

and

php artisan route:clear
about 4 years ago · Juan Pablo Isaza Denunciar

0

Named routes allow the convenient generation of URLs or redirects for specific routes. You may specify a name for a route by chaining the name method onto the route definition:

Route::get('AgencyExpenses',[AgencyExpController::class, 'expense'])
    ->name('agency.expense');

Try to change your AJAX URL :

{
    type    : "get",
    url     : "{{ route('agency.expense') }}",
    dataType: "json",
},

PS : Don't forget to clear route :

php artisan route:clear
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda